package com.by.toolkit.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Tian Wei
 * @version 1.0
 * @date 2024/3/29 12:10 PM
 */
@Getter
@AllArgsConstructor
public enum ExternalChatEnum {


    CREATE_GROUP(ExternalChatEnum.CREATE_GROUP_CODE, "客户群创建"),
    UPDATE_GROUP(ExternalChatEnum.UPDATE_GROUP_CODE, "客户群变更"),
    DISMISS_GROUP(ExternalChatEnum.DISMISS_GROUP_CODE, "客户群解散"),
    ;

    private final String changeType;

    private final String desc;

    private static final Map<String, ExternalChatEnum> MAP;

    static {
        MAP = Stream.of(ExternalChatEnum.values()).collect(Collectors.toMap(ExternalChatEnum::getChangeType, Function.identity()));
    }

    public static ExternalChatEnum resolveByChangeType(String changeType){
        return MAP.get(changeType);
    }

    public static final String CREATE_GROUP_CODE = "create";

    public static final String UPDATE_GROUP_CODE = "update";

    public static final String DISMISS_GROUP_CODE = "dismiss";
}
